#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>

typedef struct BinTree
{
    char val;
    struct BinTree* left;
    struct BinTree* right;
}BT;

BT* BuyNode(char ch)
{
    BT* tmp = (BT*)malloc(sizeof(BT));
    tmp->left = tmp->right = NULL;
    tmp->val = ch;
    return tmp;
}

BT* Create(char* s, int* i)
{
    if (s[*i] == '#')
    {
        (*i)++;
        return NULL;
    }
    BT* root = BuyNode(s[*i]);
    (*i)++;
    root->left = Create(s, i);
    root->right = Create(s, i);

    return root;
}

void Inorder(BT* root)
{
    if (root == NULL)
        return;
    Inorder(root->left);
    printf("%c ", root->val);
    Inorder(root->right);
}

int main() {
    char str[100];
    scanf("%s", str);
    int i = 0;
    BT* root = Create(str, &i);

    Inorder(root);

    return 0;
}